package com.ruoyi.api.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DzKecheng;
import com.ruoyi.system.service.IDzKechengService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * kechengController
 * 
 * @author ruoyi
 * @date 2022-09-01
 */
@RestController
@RequestMapping("/api/kecheng")
public class DzKechengApiController extends BaseController
{
    @Autowired
    private IDzKechengService dzKechengService;

    /**
     * 查询kecheng列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DzKecheng dzKecheng)
    {
        startPage();
        List<DzKecheng> list = dzKechengService.selectDzKechengListWeb(dzKecheng);
        return getDataTable(list);
    }

    /**
     * 导出kecheng列表
     */
    @Log(title = "kecheng", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DzKecheng dzKecheng)
    {
        List<DzKecheng> list = dzKechengService.selectDzKechengListWeb(dzKecheng);
        ExcelUtil<DzKecheng> util = new ExcelUtil<DzKecheng>(DzKecheng.class);
        util.exportExcel(response, list, "kecheng数据");
    }

    /**
     * 获取kecheng详细信息
     */
    @GetMapping(value = "/{kcId}")
    public AjaxResult getInfo(@PathVariable("kcId") Long kcId)
    {
        return AjaxResult.success(dzKechengService.selectDzKechengByKcId(kcId));
    }

    /**
     * 新增kecheng
     */
    @Log(title = "kecheng", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DzKecheng dzKecheng)
    {
        return toAjax(dzKechengService.insertDzKecheng(dzKecheng));
    }

    /**
     * 修改kecheng
     */
    @Log(title = "kecheng", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DzKecheng dzKecheng)
    {
        return toAjax(dzKechengService.updateDzKecheng(dzKecheng));
    }

    /**
     * 删除kecheng
     */
    @Log(title = "kecheng", businessType = BusinessType.DELETE)
	@DeleteMapping("/{kcIds}")
    public AjaxResult remove(@PathVariable Long[] kcIds)
    {
        return toAjax(dzKechengService.deleteDzKechengByKcIds(kcIds));
    }
}
